<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
  <title>抱团商家</title>
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no,minimal-ui,viewport-fit=cover"/>
  <meta name="keywords" content="抱团">
  <meta name="description" content="抱团">
  <script type="text/javascript" src="../common/js/base.js" charset="UTF-8"></script>
  <link rel="stylesheet" type="text/css" href="../common/css/elementui.min.css">
  <link rel="stylesheet" type="text/css" href="../common/css/animate.min.css">
  <link rel="stylesheet" type="text/css" href="../common/css/nanoscroller.css">
  <link rel="stylesheet" type="text/css" href="../common/css/swiper-bundle.min.css">
  <link rel="stylesheet" type="text/css" href="../common/css/base.css">
  <link rel="stylesheet" type="text/css" href="css/style.css">
  <script type='text/javascript' src="../common/js/jquery.min.js" charset="UTF-8"></script>
  <script type='text/javascript' src="../common/js/jquery.easing.js" charset="UTF-8"></script>
  <script type='text/javascript' src="../common/js/html2canvas.min.js" charset="UTF-8"></script>
  <script type="text/javascript" src="../common/js/layer/layer.js" charset="UTF-8"></script>
  <script type="text/javascript" src="../common/js/wow.js" charset="UTF-8"></script>
  <script type="text/javascript" src="../common/js/vue.js" charset="UTF-8"></script>
  <script type="text/javascript" src="../common/js/vue-resource.js" charset="UTF-8"></script>
  <script type="text/javascript" src="../common/js/axios.min.js" charset="UTF-8"></script>
  <script type='text/javascript' src="../common/js/elementui.min.js" charset="UTF-8"></script>
  <script type='text/javascript' src="../common/js/jquery.nanoscroller.js" charset="UTF-8"></script>
  <script type='text/javascript' src="../common/js/swiper.animate.min.js" charset="UTF-8"></script>
  <script type='text/javascript' src="../common/js/swiper-bundle.min.js" charset="UTF-8"></script>
  <script type='text/javascript' src="../common/js/helper.js" charset="UTF-8"></script>
</head>
<body>
<div class="wrapperbox loginpage" id="app">
  <div class="img">
    <img src="images/1.png">
  </div>
  <p class="name">商家登录</p>
  <div class="message">
    <div class="input">
      <input class="mobilenum" v-model="mobile" type="text" placeholder="请输入手机号">
    </div>
    <div class="input">
      <input class="mobilenum" v-model="password" type="password" placeholder="请输入密码">
    </div>
    <div class="tip">{{error}}</div>
    <div class="button" v-on:click="login">登录</div>
  </div>


</div>
</body>
<script>
  $(function () {
    new Vue({
      el: '#app',
      data() {
        return {
          mobile: '',
          password: '',
          error: '',
        }
      },
      mounted() {
        wow = new WOW({
          animateClass: 'animated',
          offset: 0
        });
        wow.init();
      },
      created() {
        if (localStorage.getItem('merchant_token')) {
          window.location.href = 'shophome.html'
        }
      },
      methods: {
        login: function () {
          this.error = ''
          if (this.mobile === '') {
            this.error = '请输入手机号'
            return
          }
          if (this.password === '') {
            this.error = '请输入密码'
            return
          }
          merchant_post('password_login', {
            mobile: this.mobile,
            password: this.password
          }).then(res => {
            localStorage.setItem('merchant_token', res.access_token)
            localStorage.setItem('merchant', JSON.stringify(res.merchant))
            window.location.href = 'shophome.html'
          })
        },
      }
    });
  })
</script>
</html>
